package com.aramco.fion.vo
{
	import com.aramco.fion.model.FlexConstants;
	import com.aramco.fion.util.AdminUtil;
	
	import mx.collections.ArrayCollection;

	[Bindable]
	public class DashboardVo
	{
		public var table:DBTableVO = new DBTableVO(FlexConstants.R3_TABLE_01);
		public var id:String;
		public var title:String;
		public var description:String;
		public var config:XMLList;
		public var icon:String;
		public var views:Array;
		public var selections:ArrayCollection = new ArrayCollection();
		public var role:String;
		public var logoUrl:String;
		public var createdBy:String;
		public var createdOn:dateVO;
		public var changedBy:String;
		public var changedOn:dateVO;
		public var notActive:Boolean;
		public var hidden:Boolean;
		public var zorder:String;

		
		public function Dashboard()
		{
			table = new DBTableVO(FlexConstants.R3_TABLE_01);
			createdOn = new dateVO("");
			changedOn = new dateVO("");
		}
		
		public function toXML():XML
		{

			var rowXML:XML = new XML('<row/>');
			var dataXML:XML = new XML('<data/>');
			
			dataXML.@name =  AdminUtil.dashboardTableFields[0];
			dataXML.@value = id;
			rowXML.appendChild(dataXML);
			
			// Title
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[1];
			dataXML.@value = title;
			rowXML.appendChild(dataXML);
			// Description
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[2];
			dataXML.@value = description;
			rowXML.appendChild(dataXML);
			// URL to dashboard logo
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[3];
			dataXML.@value = logoUrl;
			rowXML.appendChild(dataXML);
			// Role Name
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[4];
			dataXML.@value = role;
			rowXML.appendChild(dataXML);
			// Created by
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[5];
			dataXML.@value = createdBy != null ? createdBy: "" ;
			rowXML.appendChild(dataXML);
			// Created on
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[6];
			dataXML.@value = createdOn != null ? createdOn.value.toString() : "";
			rowXML.appendChild(dataXML);
			// Last Changed by User
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[7];
			dataXML.@value = changedBy!= null ? changedBy: "" ;
			rowXML.appendChild(dataXML);
			// Changed On 
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[8];
			dataXML.@value = changedOn != null ? changedOn.value.toString() : "";
			rowXML.appendChild(dataXML);
			// Inactive flag
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[9];
			dataXML.@value = notActive ? 'X' : '';
			rowXML.appendChild(dataXML);
			// Hide dashboard in welcome screen
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[10];
			dataXML.@value = hidden ? 'X' : '';
			rowXML.appendChild(dataXML);
			// Sort Order
			dataXML = new XML('<data/>');
			dataXML.@name =  AdminUtil.dashboardTableFields[11];
			dataXML.@value = zorder;
			rowXML.appendChild(dataXML);
			
			//append dashboard  record to table action
			table = new DBTableVO("ZFI_FION_DB");
			return table.toXML().appendChild(rowXML);
		}

	}
	
}